﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace CardInChina.Data.Entity.Entity
{
    public partial class Order
    {
        public Order Load<T>()
        {
            using (CICEntities db = new CICEntities())
            {
                Order order = db.Orders.FirstOrDefault(c => c.OrdersID == this.OrdersID);

                PropertyInfo[] pis = typeof(Order).GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty);
                foreach (var p in pis)
                {
                    if (p.PropertyType == typeof(T))
                        p.GetValue(order, null);
                }
                return order;
            }
        }
    }
}
